﻿using CPPEI.Coolzon.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designer.Views
{
    public class CopyPartOperation : OperationBase
    {
        private DesignView _designView;
        private Part _lastToPastePart;
        private Part _newCopyPart;
        private PasteType _lastPasteType;
        public CopyPartOperation(DesignView designView, Part part, PasteType lastPasteType)
        {
            _designView = designView;
            _lastToPastePart = designView.ToPastePart;
            _newCopyPart = part;
            _lastPasteType = lastPasteType;
        }
        protected override void OnDo()
        {
            _designView.API_Copy(_newCopyPart);
        }

        protected override void OnUndo()
        {
            if (_lastPasteType == PasteType.Cut)
            {
                _designView.API_Cut(_lastToPastePart);
            }
            else if (_lastPasteType == PasteType.Copy)
            {
                _designView.API_Copy(_lastToPastePart);
            }
            else
            {
                _designView.API_PasteReset();
            }
        }
    }
}
